package com.gxa.controller;

import com.gxa.common.base.LayuiResultJson;
import com.gxa.common.base.R;
import com.gxa.domain.dto.*;
import com.gxa.service.SysCourseService;
import com.gxa.service.SysUserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;

@Controller
@RequestMapping("/sys_course")
public class SysCourseController {
    @Autowired
    private SysCourseService sysCourseService;
    // 查询所有系统用户-带分页
    @RequestMapping(value = "/findSysCourseAll",method = RequestMethod.GET)
    @ResponseBody
    public LayuiResultJson findSysCourseAll(Integer page, Integer limit){
        return sysCourseService.findSysCourseAll(page,limit);
    }

    //添加
    @RequestMapping(value = "/save",method = RequestMethod.POST)
    @ResponseBody
//    public R save(SysUserSaveDTO sysUserSaveDTO){//普通对象方式接收参数：默认Params
    public R save(@RequestBody SysCourseSaveDTO sysCourseSaveDTO){//接收是json格式的对象
        return sysCourseService.addSysCourse(sysCourseSaveDTO);
    }

    // 修改
    @RequestMapping(value = "/update",method = RequestMethod.POST)
    @ResponseBody
    public R update(@RequestBody SysCourseUpdateDTO sysCourseUpdateDTO){
        return sysCourseService.updateSysCourse(sysCourseUpdateDTO);
    }

    // 删除
    @RequestMapping(value = "/delete",method = RequestMethod.POST)
    @ResponseBody
    public R delete(Integer courseId){
        return sysCourseService.delSysCourseByCourseId(courseId);
    }
    // 搜索
    @RequestMapping(value = "/search",method = RequestMethod.GET)
    @ResponseBody
    public LayuiResultJson search(String courseName,Integer page,Integer limit){
        return sysCourseService.search(courseName,page,limit);
    }

}
